// 模拟数据库基础数据
const userList = [
    { name: 'YGod', account: 'YGod', password: '123456' },
    { name: 'MrTang', account: 'MrTang', password: '123456'},
    { name: 'LSKDJJ', account: 'LSKDJJ', password: '123456' },
]

export const login = (req, res) => {
    const { account, password } = req.body

    const user = userList.find(item => item.account === account && item.password === password)

    if (!user) {
        return res.send({
            status: 400,
            message: '账号密码都能错！tell me Why baby Why'
        })
    }
    res.send({
        status: 200,
        data: {
            account: user.account,
            name: user.name,
        }
    })
}

export const getUserInfo = (req, res) => {
    const { id } = req.query

    if (!id) {
        return res.status(400).send({
            status: 'error',
            message: '缺少必要参数：id'
        })
    }

    res.send({
        status: 200,
        data: {
            id,
            name: 'MrTang',
            age: 999,
        }
    })
}
